package com.dinree;

import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;

import com.orhanobut.logger.LogLevel;
import com.orhanobut.logger.Logger;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.smtt.sdk.QbSdk;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import io.realm.Realm;
import io.realm.RealmConfiguration;

/**
 * Created by ChengZhi on 2017/4/18.
 */

public class AppApplication extends com.mob.MobApplication {
    static AppApplication mInstance;

    public static Application getInstance() {
        return mInstance;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
        mInstance = this;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        UMShareAPI.get(this);
        initRealm();
        initX5();
        initLogger();
        CrashReport.initCrashReport(getApplicationContext(), "603e68448a", true);
        PlatformConfig.setWeixin("wxcd5cd90107115e6c", "c2f7e72807736830fea31e165b64e44e");
        PlatformConfig.setQQZone("1106108613", "VAAhrVsdoRi3KBfZ");
        PlatformConfig.setSinaWeibo("3594670322", "a5a4cecbfaaa8f8944050c8e248c1971", "http://120.78.199.241");
    }

    private void initRealm() {
        Realm.init(this);
        RealmConfiguration config = new RealmConfiguration.Builder()
                .name("main.realm")
                .deleteRealmIfMigrationNeeded()
                .build();
        Realm.setDefaultConfiguration(config);
    }

    private void initX5() {
        QbSdk.initX5Environment(getApplicationContext(), null);
    }

    private void initLogger() {
        Logger.init("dinree")
                .methodCount(3)
                .hideThreadInfo()
                .logLevel(LogLevel.NONE)
                .methodOffset(2);
    }


}
